home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1998 June / SGI IRIX 6.5 Applications 1998 June.iso / dist / outbox.idb / var / www / cgi-bin / webdist.cgi.z / webdist.cgi
Text File  |  1998-05-04  |  5KB  |  186 lines

  1. #!/usr/sbin/perl
  2.  
  3.  
  4. ## Copyright 1995, Silicon Graphics, Inc.
  5. ## All Rights Reserved.
  6. ##
  7. ## This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  8. ## the contents of this file may not be disclosed to third parties, copied or
  9. ## duplicated in any form, in whole or in part, without the prior written
  10. ## permission of Silicon Graphics, Inc.
  11. ##
  12. ## RESTRICTED RIGHTS LEGEND:
  13. ## Use, duplication or disclosure by the Government is subject to restrictions
  14. ## as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  15. ## and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  16. ## successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  17. ## rights reserved under the Copyright Laws of the United States.
  18.  
  19.  
  20. #__________________________________________________________
  21. #
  22. #   IRIX 6.5 disables the webdist cgi script for security
  23. #   reasons. This script will be removed entirely in the
  24. #   next release.
  25. #__________________________________________________________
  26.  
  27. # webdist feature is disabled - display a message and exit.
  28.  
  29. print <<ENDOFTEXT ;
  30. Content-type: text/html
  31.  
  32. <HTML>
  33. <HEAD><TITLE>WebDist: feature disabled.</TITLE></HEAD>
  34. <BODY><H2>WebDist: feature disabled.</H2>
  35. This feature has been disabled. To generate a Web Software
  36. Distribution Page use the tool <I>/usr/etc/webdist</I> from the command line. See the <I>webdist</I>
  37. man page for more information.
  38. </BODY>
  39. </HTML>
  40. ENDOFTEXT
  41.  
  42. exit ;
  43.  
  44. #__________________________________________________________
  45.  
  46.  
  47. # Process cgi args
  48.  
  49. if( $ENV{'REQUEST_METHOD'} eq "GET" )
  50. {
  51.    $buffer=$ENV{'QUERY_STRING'} ;
  52. }
  53. else
  54. {
  55.    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}) ;
  56. }
  57. @pairs = split(/&/, $buffer) ;
  58. foreach (@pairs)
  59. {
  60.    tr/+/ / ;
  61.    ($name,$value)=  split(/=/) ;
  62.    $value        =~ s/%(..)/pack("c",hex($1))/ge ;
  63.    $name         =~ s/%(..)/pack("c",hex($1))/ge ;
  64.  
  65.    $in{$name} = $value;
  66.  
  67. }
  68.  
  69.  
  70. # extract params
  71. $distloc=$in{distloc};
  72. $pageloc=$in{pageloc};
  73.  
  74. # trim off undesirable meta chars.
  75. $distloc =~ s/[|;]//g ;
  76. $pageloc =~ s/[|;]//g ;
  77.  
  78. if ($distloc eq "") {
  79.     &report_fatal_error("<H3>Error: Distribution Directory cannot be empty!</H3>");
  80. }
  81.  
  82.  
  83. # Execute webdist here to create the page
  84.  
  85. $pid = fork;
  86.  
  87. if ($pid == 0) {
  88.  
  89.     # set environment variable so that xconfirm window is displayed
  90.     # this var is not set in a CGI script
  91.     $ENV{"DISPLAY"} = ":0.0";
  92.  
  93.     # Close stdout so that xconfirm writes to /dev/null
  94.     close(STDOUT);
  95.     open(STDOUT, "/dev/null");
  96.  
  97.     exec("/usr/bin/X11/xconfirm",
  98.      "-c",
  99.      "-exclusive",
  100.      "-B", "Dismiss",
  101.      "-icon", "info",
  102.      "-header", "Web Software Distribution Tool",
  103.      "-noframe",
  104.      "-t", "The Web Software Distribution Page is being created.",
  105.      "-t", "This may take a few minutes if there are many products.",
  106.      "-t", "",
  107.      "-t", "You may dismiss this dialog at any time without stopping",
  108.      "-t", "the Web Distribution Tool by pressing \"Dismiss\".",
  109.      "-t", "",
  110.      "-t", "You may cancel creating this page by pressing the",
  111.      "-t", "\"Stop\" button in your Web browser (eg Netscape).");
  112.  
  113.      exit 0;
  114. }
  115.  
  116. $output = `/usr/etc/webdist $distloc $pageloc 2>&1`;
  117.  
  118. kill(2, $pid);
  119.  
  120. $filename = "/usr/tmp/webdist.$$.html";
  121.  
  122. if ($? != 0) {
  123.     &report_fatal_error($output);
  124. } else {
  125.     print "Content-type: text/html\n\n";
  126.     print "<HTML>\n";
  127.     print "<BODY BACKGROUND=\"/webdist/images/background.jpeg\">\n";
  128.     
  129.     unless (open(OUT, ">$filename")) {
  130.     print "<H3>Error: Cannot open temporary file $filename</H3>";
  131.     } else {
  132.     print OUT "$output";
  133.     print "<H3 ALIGN=CENTER>Web Software Distribution Page Created.<BR>\n";
  134.     print "(You can see what the page will look like below)</H3>\n";
  135.     print "<HR>\n";
  136.     print "<H3 ALIGN=CENTER>Installing the Web Software Distribution Page<BR>\n";
  137.     print "(Do this now, while you can still refer to this page for reference)</H3>";
  138.     print "<P>\n";
  139.     print "The new Web Software Distribution Page has been created at\n";
  140.     print "location <SAMP>$filename</SAMP>.\n";
  141.     $dist = `basename $distloc`;
  142.     chop($dist);
  143.     webdist:chop($disthost = `hostname`);
  144.     print "<P> You will need to <B>move this file</B> to\n";
  145.     print "the location <SAMP>/var/www/htdocs/dist/$dist.html</SAMP>.\n";
  146.     print "</P>\n";
  147.     print "<HR>\n";
  148.     print "<H3 ALIGN=CENTER>Using the Web Software Distribution Page</H3>\n";
  149.     print "<P>\n";
  150.     print "After installing this page, users on the network\n";
  151.     print "can install software from it by using\n";
  152.     print "the URL <SAMP>http://$disthost/dist/$dist.html</SAMP>.\n";
  153.     print "</P>\n";
  154.     print "<HR>\n";
  155.     print "<P>\n";
  156.     print "The following is what the new Web Software Distribution Page will look like:";
  157.     print "</P>\n";
  158.     print "<HR>\n";
  159.     print "$output";
  160.     }
  161.  
  162. }
  163.  
  164.  
  165. #
  166. # Report fatal error 
  167. #
  168.  
  169. sub report_fatal_error {
  170.     local ($msg) = @_;
  171.  
  172.     print "Content-type: text/html\n\n";
  173.     print "<HTML>\n";
  174.     print "<HEAD>\n";
  175.     print "<BODY BACKGROUND=\"/webdist/images/background.jpeg\">\n";
  176.     print "<TITLE>Web Software Distribution Tool Error</TITLE>\n";
  177.     print "</HEAD>\n";
  178.     print "<BODY BACKGROUND=\"webdist/images/background.jpeg\">\n";
  179.     print "<H3>Web Software Distribution Tool Error</H3>\n";
  180.     print "$msg<P>\n";
  181.     print "Return to <A HREF=../webdist.html>webdist</A> page.";
  182.     print "</BODY>\n";
  183.  
  184.     exit 1;
  185. }
  186.